#include <iostream>
#include <cstring>
#if 0
class Student
{
    public:
    Student(const char * name, int age, float score):m_name(name), m_age(age), m_score(score)
    {
        m_total++;//操作静态成员变量
    }   
    void show()
    {
        std::cout<<m_name<<"的年龄是"<<m_age<<",成绩是"<<m_score<<"共有"<<m_total<<"名学生"<<std::endl;

    }
    private:
    static int m_total;//静态成员变量
    
    private:
    const char * m_name;
    int m_age;
    float m_score;

};
int Student::m_total = 0;//在类的外部初始化

int main()
{
    (new Student("zhangsan", 15, 90))->show();
    (new Student("lisi", 18, 95))->show();
    (new Student("wangwu", 15, 99))->show();

    return 0;
}
#endif

class Student
{
    public:
    Student(std::string name, int age, float score);
    void show();
    public: //声明静态成员函数
        static int getTotal();
        static float getPoints();
    private:
        static int m_total;
        static float m_points;

    private:
    std::string m_name;
    int m_age;
    float m_score;
};

int Student::m_total = 0;
float Student::m_points = 0.0;

Student::Student(std::string name, int age, float score):m_name(name), m_age(age), m_score(score)
{
    m_total++;
    m_points += score;
}
void Student::show()
{
    std::cout<<m_name<<"的年龄是"<<m_age<<", 的成绩是"<<m_score<<std::endl;

}
//定义静态成员函数
int Student::getTotal()
{
    return m_total;
}
float Student::getPoints()
{
    return m_points;
}

int main()
{
    (new Student("zhangsan", 15, 90))->show();
    (new Student("lisi", 18, 95))->show();
    (new Student("wangwu", 15, 99))->show();
    int total = Student::getTotal();
    float points = Student::getPoints();

    std::cout<<"当前共有"<<total<<"名学生,总成绩是"<<points<<std::endl;
    
    return 0;
}